/**
 * <copyright>
 * </copyright>
 *

 */
package br.ufrn.dimap.processDsl.impl;

import br.ufrn.dimap.processDsl.ProcessDslPackage;
import br.ufrn.dimap.processDsl.Role;
import br.ufrn.dimap.processDsl.RoleElement;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Role Element</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link br.ufrn.dimap.processDsl.impl.RoleElementImpl#getRoles <em>Roles</em>}</li>
 *   <li>{@link br.ufrn.dimap.processDsl.impl.RoleElementImpl#getPrimacy <em>Primacy</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class RoleElementImpl extends MinimalEObjectImpl.Container implements RoleElement
{
  /**
   * The cached value of the '{@link #getRoles() <em>Roles</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRoles()
   * @generated
   * @ordered
   */
  protected Role roles;

  /**
   * The default value of the '{@link #getPrimacy() <em>Primacy</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPrimacy()
   * @generated
   * @ordered
   */
  protected static final String PRIMACY_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getPrimacy() <em>Primacy</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPrimacy()
   * @generated
   * @ordered
   */
  protected String primacy = PRIMACY_EDEFAULT;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected RoleElementImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return ProcessDslPackage.Literals.ROLE_ELEMENT;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Role getRoles()
  {
    if (roles != null && roles.eIsProxy())
    {
      InternalEObject oldRoles = (InternalEObject)roles;
      roles = (Role)eResolveProxy(oldRoles);
      if (roles != oldRoles)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, ProcessDslPackage.ROLE_ELEMENT__ROLES, oldRoles, roles));
      }
    }
    return roles;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Role basicGetRoles()
  {
    return roles;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setRoles(Role newRoles)
  {
    Role oldRoles = roles;
    roles = newRoles;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ProcessDslPackage.ROLE_ELEMENT__ROLES, oldRoles, roles));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getPrimacy()
  {
    return primacy;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPrimacy(String newPrimacy)
  {
    String oldPrimacy = primacy;
    primacy = newPrimacy;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ProcessDslPackage.ROLE_ELEMENT__PRIMACY, oldPrimacy, primacy));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case ProcessDslPackage.ROLE_ELEMENT__ROLES:
        if (resolve) return getRoles();
        return basicGetRoles();
      case ProcessDslPackage.ROLE_ELEMENT__PRIMACY:
        return getPrimacy();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case ProcessDslPackage.ROLE_ELEMENT__ROLES:
        setRoles((Role)newValue);
        return;
      case ProcessDslPackage.ROLE_ELEMENT__PRIMACY:
        setPrimacy((String)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case ProcessDslPackage.ROLE_ELEMENT__ROLES:
        setRoles((Role)null);
        return;
      case ProcessDslPackage.ROLE_ELEMENT__PRIMACY:
        setPrimacy(PRIMACY_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case ProcessDslPackage.ROLE_ELEMENT__ROLES:
        return roles != null;
      case ProcessDslPackage.ROLE_ELEMENT__PRIMACY:
        return PRIMACY_EDEFAULT == null ? primacy != null : !PRIMACY_EDEFAULT.equals(primacy);
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (primacy: ");
    result.append(primacy);
    result.append(')');
    return result.toString();
  }

} //RoleElementImpl
